<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <title>Title</title>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <nav class="navbar navbar-default">
                <div class="container-fluid">
                    <!-- Brand and toggle get grouped for better mobile display -->
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="#">班主任管理</a>
                    </div>

                    <!-- Collect the nav links, forms, and other content for toggling -->
                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                        <ul class="nav navbar-nav">
                            <li ><a href="/tp.do?key=LoginTask.home">我的班级</a></li>
                            <li class="active"><a href="/tp.do?key=HeadTask.findleave">请假申请</a></li>
                        </ul>

                        <ul class="nav navbar-nav navbar-right">
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">欢迎您，${loginUser.name}<span class="caret"></span></a>
                                <ul class="dropdown-menu">
                                    <li><a href="/login/loginout">退出</a></li>
                                </ul>
                            </li>
                        </ul>
                    </div><!-- /.navbar-collapse -->
                </div><!-- /.container-fluid -->
            </nav>

        </div>
    </div>
    <div class="row">
        <div class="col-md-8">
            <form class="form-inline" role="form" method="get" action="tp.do" id="form_search">
                <label>类型:</label>
                <select class="form-control" style="width:105px" id="type" name="status">
                    <option value="0">全部</option>
                    <option value="3">未审核</option>
                    <option value="1">已通过</option>
                    <option value="2">已驳回</option>
                </select>
                <input type="hidden" name="key" value="HeadTask.findleave">
                <button type="submit" class="btn btn-default" id="sera">搜索</button>
            </form>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-hover" id="tbd">
                <thead>
                <tr>
                    <td>#</td>
                    <td>学号</td>
                    <td>姓名</td>
                    <td>原因</td>
                    <td>时间段</td>
                    <td>申请时间</td>
                    <td>附件</td>
                    <td>状态</td>
                    <td>操作</td>
                </tr>
                </thead>
                <tbody>
                <#list absentnote as member>
                <tr>
                    <td>${member_index+1}</td>
                    <td>${member.user.code}</td>
                    <td>${member.user.name}</td>
                    <td>${member.reason}</td>
                    <td>${member.period}</td>
                    <td>${member.timeStr}</td>
                    <td>
                        <#if member.extfile=="">
                        无
                        <#else>
                        <a href="/pic/${member.extfile}" download="/pic/${member.extfile}">下载</a>
                    </#if>
                </td>
                <td>
                    <#if member.managercfm==0>
                    未审核
                    <#elseif member.managercfm==1>
                    审核通过
                    <#elseif member.managercfm==2>
                    已驳回
                </#if>
                </td>
                <td>
                    <#if member.managercfm==0>
                    <button type="button" class="btn btn-success" ><span class="glyphicon glyphicon-pencil edit_btn" onclick="editbut(${member.id})">操作</span></button>
                    <#else>
                   已批阅
                </#if>

                </td>

                </tr>
                </#list>
                </tbody>
            </table>
        </div>
    </div>
</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">同意</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal">
                <div class="form-group" style="display: none;">
                    <label  class="col-sm-2 control-label">id</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control"  id="id" placeholder="text" name="id">
                    </div>
                </div>
                    <div class="form-group" >
                        <label  class="col-sm-2 control-label">意见：</label>
                        <div class="col-sm-10">
                            <textarea class="form-control" rows="3" name="managermark">早去早回</textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-2 control-label">审核</label>
                        <div class="col-sm-10">
                            <select class="form-control"  name="managercfm">
                                <option value="1">同意</option>
                                <option value="2">驳回</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-success" id="et_but">确认</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

</body>
<script>
    function editbut(id) {
        $("#myModal").modal({
            backdrop:false
        });
        $("#id").val(id);
    }

    $("#et_but").click(function () {

        $.ajax({
            url:"/head/approvalLeave",
            type:"post",
            data:$("#myModal form").serialize(),
            success:function (result) {
                $("#myModal").modal("hide");
            }
        });
    });

</script>
</html>